import axios from 'axios'

function ajax_get(path, params) {
    return new Promise(function (resolve, reject) {
        axios.get(path, {
            params
        }).then(result => {
            resolve(result.data)
        })
    })
}

function ajax_post(path,params){
    return new Promise(function(resolve,reject){
        axios.post(path,params).then(result=>{
            resolve(result.data);
        })
    })
}
function ajax_guessCity(params, id) {
    return ajax_get(`/myE/v1/cities/${id}`, params);
}

function ajax_dingCity(params, geohash) {
    return ajax_get(`/myE/v2/pois/${geohash}`, params);
}

function ajax_shopLie(params) {
    return ajax_get('/myE/v2/index_entry');
}

function ajax_jinShop(params) {
    return ajax_get('/myE/shopping/restaurants', params)
}
function ajax_search(params){
    return ajax_get('/myE/v4/restaurants',params);
}
function ajax_login(params){
    return ajax_post('/myE/v2/login',params);
}
function ajax_capTcha(params){
    return ajax_post("/myE/v1/captchas",params);
}
function ajax_user(params){
    return ajax_get('/myE/v1/user',params);
}
function ajax_fenLei(params){
    return ajax_get('/myE/shopping/v2/restaurant/category',params);
}
export {
    ajax_guessCity,
    ajax_dingCity,
    ajax_shopLie,
    ajax_jinShop,
    ajax_search,
    ajax_login,
    ajax_capTcha,
    ajax_user,
    ajax_fenLei,
}